<template>
	<div style="display: flex;justify-content: space-between;">
		<h3>教师列表</h3>
		<h3>
			<button @click="go2Add()">添加新教师</button>
		</h3>
	</div>
	<div style="width: 100%;border: 1px solid blue;">
		<table border="1" style="width: 100%;">
			<tr v-for="(x,dix) in teas">
				<td>{{x.uid}}</td>
				<td>{{x.uname}}</td>
				<td>{{x.phone}}</td>
				<td>
					<div style="width: 10vw;height: 10vw">
						 <img v-bind:src="this.$ip+'/api/public/showimg/'+x.pic" style="height: 98%; width: 100%;" >
					</div>
				</td>
				<td><button @click="go2Update(x.uid)">修改</button></td>
				<td><button @click="del(x.uid)">删除</button></td>
			</tr>
		</table>
	</div>
</template>

<script>
	export default{
		data() {
			return{
				teas:[],
				tea:{},
			}
		},
		methods:{
			go2Add(){
				this.$router.push({
					path:"/adm/tea/add",
					query:{
						uid:0
					}
				});
			},
			go2Update(id){
				this.$router.push({
					path:"/adm/tea/add",
					query:{
						uid:id
					}
				});
			},
			del(id){
				this.$get("/api/adm/tea/del?uid="+id)
				.then((resp)=>{
					console.log(resp.data.data)
					this.teas = resp.data.data;
				})
			}
			
		},
		mounted() {
			this.token = window.localStorage.getItem("token");
			const headers1 = {  //定义请求头
				'Authorization':'Bearer '+ this.token
			};
			console.log("token="+this.token)
			this.$get("/api/adm/tea/findAll")
			.then((resp)=>{
				console.log(resp.data.data)
				this.teas = resp.data.data;
			})
		}
	}
</script>

<style>
</style>
